using System;
using System.Collections.Generic;
using DotNetNuke.Common.Utilities;

namespace Code5Systems.FormMaster.Business
{


	public class FormPageController
	{
		
#region C5SLLC_FormPage Methods
		/// -----------------------------------------------------------------------------
		/// <summary>
		/// retrieves a C5SLLC_FormPage from the database
		/// </summary>
		/// <remarks>
		/// </remarks>
		/// <history>
		/// </history>
		/// -----------------------------------------------------------------------------
		public FormPageInfo GetFormPage(int formPageID)
		{
			return ((FormPageInfo) (DotNetNuke.Common.Utilities.CBO.FillObject(Code5Systems.FormMaster.Data.DataProvider.Instance().GetFormPage(formPageID), typeof(FormPageInfo))));
		}
		
		/// -----------------------------------------------------------------------------
		/// <summary>
		/// retrieves a collection of C5SLLC_FormPages from the database
		/// </summary>
		/// <remarks>
		/// </remarks>
		/// <history>
		/// Generated by CodeSmith on Saturday, August 27, 2011
		/// </history>
		/// -----------------------------------------------------------------------------
		public List<FormPageInfo> ListFormPages()
		{
			return CBO.FillCollection<FormPageInfo>(Code5Systems.FormMaster.Data.DataProvider.Instance().ListFormPages());
		}
		/// -----------------------------------------------------------------------------
		/// <summary>
		/// retrieves a collection of C5SLLC_FormPages from the database by FormID using
		/// FK_C5SLLC_FormPage_C5SLLC_Form
		/// </summary>
		/// <remarks>
		/// </remarks>
		/// <history>
		/// Generated by CodeSmith on Saturday, August 27, 2011
		/// </history>
		/// -----------------------------------------------------------------------------
		public List<FormPageInfo> ListFormPagesByFormID(int formID)
		{
			return CBO.FillCollection<FormPageInfo>(Code5Systems.FormMaster.Data.DataProvider.Instance().GetFormPagesByFormID(formID));
		}
		
		/// -----------------------------------------------------------------------------
		/// <summary>
		/// adds a new C5SLLC_FormPage to the database
		/// </summary>
		/// <remarks>
		/// </remarks>
		/// <history>
		/// Generated by CodeSmith on Saturday, August 27, 2011
		/// </history>
		/// -----------------------------------------------------------------------------
		public int AddFormPage(FormPageInfo objFormPage)
		{
			return Code5Systems.FormMaster.Data.DataProvider.Instance().AddFormPage(objFormPage.FormID, objFormPage.PageNum, objFormPage.TableColumns, objFormPage.TableRows, objFormPage.LabelPosition, objFormPage.Title, objFormPage.ShortName, objFormPage.PageData, objFormPage.UseTitle, objFormPage.ExtIdentityColumn, objFormPage.ExtTableConnStr, objFormPage.ExtTableName, objFormPage.CreatedByID, objFormPage.CreatedDate, objFormPage.LastModifiedByID, objFormPage.LastModifiedDate);
		}
		
		/// -----------------------------------------------------------------------------
		/// <summary>
		/// saves a C5SLLC_FormPage to the database
		/// </summary>
		/// <remarks>
		/// </remarks>
		/// <history>
		/// Generated by CodeSmith on Saturday, August 27, 2011
		/// </history>
		/// -----------------------------------------------------------------------------
		public void UpdateFormPage(FormPageInfo objFormPage)
		{
			objFormPage.LastModifiedDate = DateTime.Now;
			Code5Systems.FormMaster.Data.DataProvider.Instance().UpdateFormPage(objFormPage.FormPageID, objFormPage.FormID, objFormPage.PageNum, objFormPage.TableColumns, objFormPage.TableRows, objFormPage.LabelPosition, objFormPage.Title, objFormPage.ShortName, objFormPage.PageData, objFormPage.UseTitle, objFormPage.ExtIdentityColumn, objFormPage.ExtTableConnStr, objFormPage.ExtTableName, objFormPage.CreatedByID, objFormPage.CreatedDate, objFormPage.LastModifiedByID, objFormPage.LastModifiedDate);
		}
		
		/// -----------------------------------------------------------------------------
		/// <summary>
		/// deletes a C5SLLC_FormPage from the database
		/// </summary>
		/// <remarks>
		/// </remarks>
		/// <history>
		/// Generated by CodeSmith on Saturday, August 27, 2011
		/// </history>
		/// -----------------------------------------------------------------------------
		public void DeleteFormPage(int formPageID)
		{
			Code5Systems.FormMaster.Data.DataProvider.Instance().DeleteFormPage(formPageID);
		}
		
		public void DeleteFormPageByFormID(int formID)
		{
			Code5Systems.FormMaster.Data.DataProvider.Instance().DeleteFormPageByFormID(formID);
		}
		
		public void DeleteFormPageByPageNum(int formID, int pageNum)
		{
			Code5Systems.FormMaster.Data.DataProvider.Instance().DeleteFormPageByPageNum(formID, pageNum);
		}
		
		public void ResetPage(FormPageInfo oPage)
		{
			oPage.TableColumns = (byte) 1;
			oPage.TableRows = (byte) 1;
			oPage.LabelPosition = (byte) 1;
			oPage.PageData = Constants.DEFAULT_PAGE;
			oPage.LastModifiedDate = DateTime.Now;
		}
		
#endregion
		
		private static object GetNull(object Field)
		{
			return Null.GetNull(Field, DBNull.Value);
		}
		
	}
}

